//
//  HJBaseViewController.swift
//  sinaWeibo
//
//  Created by hjun on 16/3/21.
//  Copyright © 2016年 hjun. All rights reserved.
//

import UIKit

class HJBaseViewController: UITableViewController{
    ///用户是否登录
    var userlogin = HJUserAccountViewModel.sharedInstance.userLogin
    
    override func loadView() {
        
        userlogin ? super.loadView() : setupView()
    }
    ///设置访客登录视图
    func setupView(){
        
        view = visitorView
        
        ///5.设置代理
        visitorView.delegate = self
        
        
        if (self is HomeViewController){
            
            visitorView.rotation()
        
        }else if (self is MessageViewController){
            visitorView.setupVisitorView("visitordiscover_image_message", message: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
        
        }else if (self is DiscoverViewController){
            
            visitorView.setupVisitorView("visitordiscover_image_message", message: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
            
        }else if (self is ProfileViewController){
            
            visitorView.setupVisitorView("visitordiscover_image_profile", message: "登录后，你的微博、相册、个人资料会显示在这里，展示给别人")
        }
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewDidClickRegisterBtn")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewDidClickLoginBtn")
        
    }
    
    //MARK:- 懒加载
    
    private lazy var visitorView: HJVisitorView = HJVisitorView()

}


//MARK: 在拓展里实现协议，注意要把拓展的协议放在外面

 extension HJBaseViewController: HJVisitorViewDelegate{
func visitorViewDidClickRegisterBtn(){
    
//    let netWork = HJNetWorkTool.sharedInstance
    
   
    
}
func visitorViewDidClickLoginBtn(){
    
//    let netWork = HJNetWorkTool.sharedInstance
    let OauchVC = HJOauchViewController()
    
    presentViewController(UINavigationController(rootViewController: OauchVC), animated: true, completion: nil)
    
    
}

}

